<?php
$row = $this->request->data;
?>

<div class="row-fluid">
    <div class="span2">
        <div>
            <p class="nav-header">Actions</p>
            <ul class="nav nav-tabs nav-stacked">
                <li>
                    <form action="<?php echo $this->Html->url('delete/' . $row['Broker']['id']); ?>" name="post_delete" id="post_delete" style="display:none;" method="post">
                        <input type="hidden" name="_method" value="POST">
                    </form>
                    <a href="#" onclick="if (confirm('Are you sure you want to delete #<?php echo $row['Broker']['id']; ?>?')) {
                                document.post_delete.submit();
                            }
                            event.returnValue = false;
                            return false;">Delete</a>
                </li>
                <li><a href="<?php echo $this->Html->url('index/'); ?>">List Brokers</a></li>
            </ul>
        </div>
    </div>
    <div class="span10">
        <form action="<?php echo $this->Html->url('edit/' . $row['Broker']['id']); ?>" class="well" id="BrokerEditForm" method="post" accept-charset="utf-8">
            <div style="display:none;">
                <input type="hidden" name="_method" value="PUT">
            </div>        
            <fieldset>
                <legend>Edit Broker</legend>
                <input type="hidden" name="id" help="" value="<?php echo $row['Broker']['id']; ?>" id="UserId">

                <div class="control-group required">
                    <label for="Name">FullName (*)</label>
                    <input name="fullname" help="" maxlength="45" type="text" value="<?php echo $row['Broker']['fullname']; ?>" id="Name" required="required">
                </div>

                <div class="control-group required">
                    <label for="Email">Email (*)</label>
                    <input name="email" help="" maxlength="45" type="text" value="<?php echo $row['Broker']['email']; ?>" id="Email" required="required">
                </div>
                
                <div class="control-group required">
                    <label for="Company">Company (*)</label>
                    <select name="company" help="" id="Company" required="required">
                        <?php
                        foreach ($companies as $company) {
                            echo '<option value="' . $company['Company']['id'] . '" ' . ($row['Broker']['company'] == $company['Company']['id'] ? 'selected=selected' : '') . '>' . $company['Company']['name'] . '</option>';
                        }
                        ?>
                    </select>                    
                </div>

                <div class="control-group required">
                    <label for="Address">Address</label>
                    <input name="address" help="" maxlength="45" type="text" value="<?php echo $row['Broker']['address']; ?>" id="Address">
                </div>
                
                <div class="control-group required">
                    <label for="Description">Description</label>
                    <textarea name="description" help="" type="text"id="Description"><?php echo $row['Broker']['description']; ?></textarea>
                    <script>
                        // Replace the <textarea id="editor1"> with a CKEditor
                        // instance, using default configuration.
                        CKEDITOR.replace('description');
                    </script>
                </div>  

                <div class="control-group required">
                    <label for="Order">Order</label>
                    <input name="order" help="" maxlength="45" type="number" value="<?php echo $row['Broker']['order']; ?>" id="Order" required="required">
                </div> 

                <div class="control-group">
                    <label for="Status">Status</label>
                    <select name="status" help="" id="Status">
                        <option value="1" <?php echo ($row['Broker']['status'] ? 'selected=selected' : ''); ?>>Yes</option>
                        <option value="0" <?php echo (!$row['Broker']['status'] ? 'selected=selected' : ''); ?>>No</option>
                    </select>
                </div>
            </fieldset>        
            <div class="submit">
                <input class="btn btn-primary" type="submit" value="Save">
            </div>
        </form>    
    </div>
</div>